#!/bin/sh

remote_param_list="\n
TZSYSTEM_REMOTE_LOGIN="TZ_REMOTE_LOGIN"\n
TZSYSTEM_REMOTE_PING="TZ_REMOTE_PING"\n
TZSYSTEM_REMOTE_DEFAULT_LIST_AUTH="TZ_REMOTE_DEFAULT_LIST_AUTH"\n
"

param_file_remote=/tmp/.param_file_remote
extern_file=$1

if [ ! -e "${extern_file}" ]; then
	exit
fi

cat $extern_file | grep TZSYSTEM_REMOTE > ${param_file_remote}


#
while read line
do
        name=`echo $line | awk -F "=" '{print$1}' | awk '{print $2}'`
        value=`echo $line | awk -F "=" '{print$2}' | awk -F '"' '{print $2}'`

        name_in_remote_param=`echo -e ${remote_param_list} | grep ${name} | awk -F "=" '{print $2}'`
        if [ -n "${name_in_remote_param}" ]; then
        	uci set tozed.remote_control.${name_in_remote_param}="${value}"
        fi

done < ${param_file_remote}

cfg -c
